package battlefield;

import MemoryDB.YuanTable;
import Public.PlayerPublicFun;

public class BattleFiledRewards extends BattleFieldPublic
{
	private int rewardExp = 0;

	public final int getRewardExp()
	{
		return rewardExp;
	}
	public final void setRewardExp(int value)
	{
		rewardExp = value;
	}
	private int rewardPVPPoint = 0;

	public final int getRewardPVPPoint()
	{
		return rewardPVPPoint;
	}
	public final void setRewardPVPPoint(int value)
	{
		rewardPVPPoint = value;
	}
	private int rewardMoney = 0;

	public final int getRewardMoney()
	{
		return rewardMoney;
	}
	public final void setRewardMoney(int value)
	{
		rewardMoney = value;
	}
	private int rewardItemID = 0;

	public final int getRewardItemID()
	{
		return rewardItemID;
	}
	public final void setRewardItemID(int value)
	{
		rewardItemID = value;
	}

	private String mapID;
	private int maxPlayerCount;

	public BattleFiledRewards(String mapID, int playerCount)
	{
		this.mapID = mapID;
		this.maxPlayerCount = playerCount;
	}

	public final BattleFiledRewards getReward(boolean isWin)
	{
		YuanTable ytBattleField = null;
		String dataKey = this.mapID.toString() + (new Integer(this.maxPlayerCount)).toString();
		ytBattleField = PlayerPublicFun.getBattlefieldData().get(dataKey);
		if (ytBattleField != null)
		{
			if (isWin)
			{
				this.rewardExp = Integer.parseInt(ytBattleField.getItem(0).getItem("winExp").getYuanColumnText());
				this.rewardPVPPoint = Integer.parseInt(ytBattleField.getItem(0).getItem("winPVPPoint").getYuanColumnText());
				this.rewardMoney = Integer.parseInt(ytBattleField.getItem(0).getItem("winMoney").getYuanColumnText());
				this.rewardItemID = Integer.parseInt(ytBattleField.getItem(0).getItem("winItemID").getYuanColumnText());
			}
			else
			{	
				this.rewardExp = Integer.parseInt(ytBattleField.getItem(0).getItem("loseExp").getYuanColumnText());
				this.rewardPVPPoint = Integer.parseInt(ytBattleField.getItem(0).getItem("losePVPPoint").getYuanColumnText());
				this.rewardMoney = Integer.parseInt(ytBattleField.getItem(0).getItem("loseMoney").getYuanColumnText());
				this.rewardItemID = Integer.parseInt(ytBattleField.getItem(0).getItem("loseItemID").getYuanColumnText());
			}
		}

		return this;
	}
}